<template>
  <div class="base-l" v-loading="loadingShow">
    <el-form ref="form" :model="formData" label-width="220px">
      <div class="shuju_title mar_b20 mar_t20">
        <div class="shuju_title_text">
          <span>支付设置</span>
        </div>
      </div>
      <el-form-item label="微信/支付宝支付">
        <el-radio-group v-model="formData.aliPay">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="2">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <template v-if="formData.aliPay == 1">
        <el-form-item label="支付宝AppId">
          <el-input type="text" v-model="formData.aliAppId" placeholder="请输入支付宝AppId"></el-input>
        </el-form-item>
        <el-form-item label="支付宝公钥" class="textareaWitd">
          <el-input type="textarea" v-model="formData.publicKey" :rows="6" placeholder="请输入支付宝公钥"></el-input>
        </el-form-item>
        <el-form-item label="支付宝应用私钥" class="textareaWitd">
          <el-input type="textarea" v-model="formData.privateKey" :rows="8" placeholder="请输入支付宝应用私钥"></el-input>
        </el-form-item>
      </template>
      <el-form-item label="余额支付">
        <el-radio-group v-model="formData.balance">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="2">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="现金支付">
        <el-radio-group v-model="formData.cash">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="2">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="其他支付">
        <el-radio-group v-model="formData.otherSet" disabled>
          <el-radio :label="1">是</el-radio>
          <el-radio :label="2">否</el-radio>
        </el-radio-group>
      </el-form-item>
<!--      <div class="shuju_title mar_b20">-->
<!--        <div class="shuju_title_text">-->
<!--          <span>抹零设置</span>-->
<!--        </div>-->
<!--      </div>-->
<!--      <el-form-item label="状态">-->
<!--        <el-radio-group v-model="formData.discountStatus">-->
<!--          <el-radio :label="1">启用</el-radio>-->
<!--          <el-radio :label="2">不启用</el-radio>-->
<!--        </el-radio-group>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="抹零方式" v-if="formData.discountStatus == 1">-->
<!--        <el-radio-group v-model="formData.discountType">-->
<!--          <el-radio :label="1">抹分</el-radio>-->
<!--          <el-radio :label="2">抹角</el-radio>-->
<!--          <el-radio :label="3">四舍五入到角</el-radio>-->
<!--          <el-radio :label="4">四舍五入到元</el-radio>-->
<!--        </el-radio-group>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="自动抹零">-->
<!--        <el-radio-group v-model="formData.discountAuto">-->
<!--          <el-radio :label="1">启用</el-radio>-->
<!--          <el-radio :label="2">不启用</el-radio>-->
<!--        </el-radio-group>-->
<!--      </el-form-item>-->
      <div class="shuju_title mar_b20">
        <div class="shuju_title_text">
          <span>权限设置</span>
        </div>
      </div>
      <el-form-item label="功能">
        <div class="flex">
          <div class="mar_l20">
            <el-checkbox-group v-model="formData.cashier">
              <el-checkbox :true-label="1" :false-label="2">收银功能</el-checkbox>
            </el-checkbox-group>
          </div>
          <div class="mar_l20">
            <el-checkbox-group v-model="formData.fastFood">
              <el-checkbox :true-label="1" :false-label="2">快餐功能</el-checkbox>
            </el-checkbox-group>
          </div>
        </div>
      </el-form-item>
        <el-form-item label="下单绑定会员提示">
          <el-radio-group v-model="formData.vipTips">
            <el-radio :label="1">开启</el-radio>
            <el-radio :label="2">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
<!--      <div class="shuju_title mar_b20">-->
<!--        <div class="shuju_title_text">-->
<!--          <span>打印设置</span>-->
<!--        </div>-->
<!--      </div>-->
<!--      <el-form-item label="自动打印小票">-->
<!--        <el-radio-group v-model="formData.state">-->
<!--          <el-radio :label="1">启用</el-radio>-->
<!--          <el-radio :label="2">不启用</el-radio>-->
<!--        </el-radio-group>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="打印交班小票">-->
<!--        <el-radio-group v-model="formData.state">-->
<!--          <el-radio :label="1">启用</el-radio>-->
<!--          <el-radio :label="2">不启用</el-radio>-->
<!--        </el-radio-group>-->
<!--      </el-form-item>-->
    </el-form>
  </div>
</template>

<script>
import { postConfig, getConfig } from '@/api/setup.js';
// import baiduUeditor from '@/plugins/baidu-ueditor';
export default {
  data() {
    return {
      loadingShow: true,
      formData: {
        ident: 'cashierSet',
        aliPay: 1,
        aliAppId: '',
        privateKey: '',
        publicKey: '',
        balance: 1,
        cash: 1,
        otherSet: 1,
        cashier: 1,
        fastFood: 1,
        discountStatus: 1,
        discountType: 1,
        discountAuto: 1,
        vipTips: 1,
      },
      keyName: ''
    };
  },
  created() {
    getConfig({ ident: 'cashierSet' }).then((res) => {
      if (res.code == 1) {
        Object.assign(this.formData, res.data);
        setTimeout(() => {
          this.loadingShow = false;
        }, 500);
      }
    });
  },
  methods: {
    getUeditor() {},
    submit() {
      postConfig(this.formData).then((res) => {
        if (res.code == 1) {
          this.$baseMessage('保存成功！', 'success');
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.textareaWitd .el-form-item__content .el-textarea {
  width: 800px;
}
</style>

